export const $ = el => {
  console.log('aaaa', document.querySelector(el))
  return document.querySelector(el)
}

export const $all = (el, parent = document) => [...parent.querySelectorAll(el)]


export const getQuery = () => {
  const search = location.search.slice(1)
  if (!search) return {}
  return search.split('&').reduce((prev, item) => {
    const [key, val] = item.split('=')
    if (prev[key]) {
      if (Array.isArray(prev[key])) {
        prev[key].push(val)
      } else {
        prev[key] = [prev[key], val]
      }
    } else {
      prev[key] = val
    }
    return prev
  }, {})
}